using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gko.Utils
{
	public class Task : TaskBase
	{
		private Task(string name, int priority, Func<ITask, ProceedResult> proceed, Func<ProceedResult, ProceedResult> complete)
			: base(name, priority, complete)
		{
			this.ProceedFunc = proceed;
		}

		private Func<ITask, ProceedResult> ProceedFunc
		{
			get;
			set;
		}

		public static Task Create(string name, int priority, Func<ITask, ProceedResult> proceed)
		{
			return new Task(name, priority, proceed, null);
		}

		public static Task Create(string name, int priority, Func<ProceedResult> proceed)
		{
			return new Task(name, priority, p => proceed(), null);
		}

		public static Task Create(string name, int priority, Func<ProceedResult> proceed, Func<ProceedResult, ProceedResult> complete)
		{
			return new Task(name, priority, p => proceed(), complete);
		}

		public override ProceedResult Proceed()
		{
			return this.ProceedFunc(this);
		}
	}
}